/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package anjos.modelo;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Junior
 */
@Entity
@Table(name = "anjo_evento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AnjoEvento.findAll", query = "SELECT a FROM AnjoEvento a"),
    @NamedQuery(name = "AnjoEvento.findByAnjoId", query = "SELECT a FROM AnjoEvento a WHERE a.anjoEventoPK.anjoId = :anjoId"),
    @NamedQuery(name = "AnjoEvento.findByEventoId", query = "SELECT a FROM AnjoEvento a WHERE a.anjoEventoPK.eventoId = :eventoId"),
    @NamedQuery(name = "AnjoEvento.findBySenha", query = "SELECT a FROM AnjoEvento a WHERE a.senha = :senha")})
public class AnjoEvento implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AnjoEventoPK anjoEventoPK;
    @Size(max = 45)
    @Column(name = "senha")
    private String senha;
    @JoinColumn(name = "evento_id", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Evento evento;
    @JoinColumn(name = "anjo_id", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Anjo anjo;

    public AnjoEvento() {
    }

    public AnjoEvento(AnjoEventoPK anjoEventoPK) {
        this.anjoEventoPK = anjoEventoPK;
    }

    public AnjoEvento(int anjoId, int eventoId) {
        this.anjoEventoPK = new AnjoEventoPK(anjoId, eventoId);
    }

    public AnjoEventoPK getAnjoEventoPK() {
        return anjoEventoPK;
    }

    public void setAnjoEventoPK(AnjoEventoPK anjoEventoPK) {
        this.anjoEventoPK = anjoEventoPK;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    public Evento getEvento() {
        return evento;
    }

    public void setEvento(Evento evento) {
        this.evento = evento;
    }

    public Anjo getAnjo() {
        return anjo;
    }

    public void setAnjo(Anjo anjo) {
        this.anjo = anjo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (anjoEventoPK != null ? anjoEventoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AnjoEvento)) {
            return false;
        }
        AnjoEvento other = (AnjoEvento) object;
        if ((this.anjoEventoPK == null && other.anjoEventoPK != null) || (this.anjoEventoPK != null && !this.anjoEventoPK.equals(other.anjoEventoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "anjos.modelo.AnjoEvento[ anjoEventoPK=" + anjoEventoPK + " ]";
    }
    
}
